|
Table of Contents
NOTE: you can find this and other lessons in a
more complete and viewable format (including all Figures) in our Tutorial PDF.
Lesson 2. How to Include Only Certain Records from the SMF File
-
This lesson teaches you how to select only certain records from the SMF file for inclusion in your report. The control statement discussed is:
-
the
INCLUDEIF
statement
How to Use the INCLUDEIF Statement
-
Let us revise something that we said in the previous lesson. The truth is that you can make a Spectrum SMF Writer report with just two control statements (the
INPUT
and
COLUMNS
statements.) When no
INCLUDEIF
statement is given, Spectrum SMF Writer includes every record from the input file in your report.
-
But since the SMF file contains dozens of different record types (each containing different kinds of data) it is not very useful to include all records in a single report. So it is safe to say that most of your reports will use an
INCLUDEIF
statement to limit the records used in a given report.
-
The
INCLUDEIF
statement tells Spectrum SMF Writer to "include" an SMF record in the report only "if" one or more conditions are met. In the example in Figure, we included records in the report if the record type field was equal to 14. So that report includes every type 14 record from the input file.
-
Most of your reports will consist of data from only one type of SMF record. But often you will want to limit the records that appear in your report even further. You do this by specifying more than one condition (or test) in the
INCLUDEIF
statement. Consider these statements:
INPUT: SMF30 /* COPY SMF30 RECORD DEFINITIONS */
INCLUDEIF: SMF30RTY = 30 AND SMF30STY = 5 /* SELECT SMF TYPE 30, SUBTYPE 5 RECS */
-
The above statements select just the type 30 with a subtype of 5 for the report. Subtype 5 records are written at job termination time, so those are a good source of job accounting information. We will use the above statements in some later examples.
-
Sometimes you may just want to look at the SMF data for one particular job, or maybe for any jobs that access a certain group of datasets. You will use the INCLUDEIF statement in such cases:
INCLUDEIF: SMF14RTY = 14 AND (SMF30JBN = 'ACCT1000' OR SMF30_JFCBDSN : 'PROD.ACCT')
-
The above statement will include any type 14 record whose jobname is 'ACCT1000' or where the dataset accessed contains the characters 'PROD.ACCT' somewhere within its DSNAME.
-
The colon comparison operator (:) is a special feature of Spectrum SMF Writer. It allows you to scan a field to see if a given text appears anywhere within it. This is a very handy feature for writing condition expressions with Spectrum SMF Writer.
-
The
INCLUDEIF
statement may appear anywhere after the
INPUT
statement. Only one
INCLUDEIF
statement is allowed per report, but it may contain as many conditions as you like.
-
By the way, the
INCLUDEIF
statement may refer to any of the fields defined for the input file (as well as any
COMPUTE
field). You are not limited to just those fields that are listed in the
COLUMNS
statement, for example.
Conditional Expressions
-
The contents of the
INCLUDEIF
statement is simply a conditional expression. The complete rules for conditional expressions are discussed in "Conditional Expressions" (page 459) in the Reference Manual. It is generally the same as for such languages as BASIC, COBOL, etc.
-
Here is a summary of some of the main syntax rules for conditional expressions:
Comparators and Logical Connectors
-
The following conditional operators are supported: <, <=, =, >=, >, and ¬= or <>. Spectrum SMF Writer also has these 2 special operators : (contains) and ¬: (does not contain) that scan a field for the specified text.
-
Your expression can contain any number of conditions, separated with the words
AND
and
OR
, optionally preceded by
NOT
, nested as needed within parentheses. You can also use the symbols
&
,
|
and ¬.
Character Literals
-
Character literals must appear within single or double quote marks. To embed the same quote character within the literal, double it. The following are all valid examples of a character literal:
-
'JONES'
-
"JONES"
-
'JONE''S'
-
"JONE'S"
-
Character literals can also be specified in hexadecimal format by prefixing the literal with an
X
, like this:
X'FFFF'
Numeric Literals
-
Numeric literals should not be contained within quotes. No punctuation is allowed other than a minus sign and a decimal point.
Date Literals
-
Date literals should be in either
MM/DD/YY
or
MM/DD/YYYY
format (leading zeros not required).
-
If you use
YY
in your date literals, it is understood to represent a year between 1951 and 2050. However, you can specify your own cutover year by specifying the CENTURY option.
-
you may want to specify the following option near the beginning of your control statements:
OPTION: DDMMYYLIT
This option indicates that all date literals in the control statements will be in
DD/MM/YY
or
DD/MM/YYYY
format.
Comparing Dates
-
One very powerful feature of Spectrum SMF Writer often takes some getting used to by programmers. If they have used other report writers, programmers are used to matching the format of their date literal with the format of the raw data in the record being tested. For example, if a record contains packed Julian dates, programmers usually have to look up the desired date in Julian and then write their comparison literal in the same packed Julian date format.
-
With Spectrum SMF Writer, this is not necessary. The program automatically handles all required date conversions for you. So, whether a raw field is stored in the record as a packed Julian date, a character
YYYYMMDD
or
MMDDYY
date, an 8-byte
STCK
date, or a binary day in century (to name a few of the formats), you always write your comparison dates in
MM/DD/[YY]YY
format.
-
As an example, even though the
SMF14DTE
field is stored in the SMF record in packed
P'CYYDDD'
format, you just test it like this:
INCLUDEIF: SMF14RTY= 14 AND SMF14DTE >= 6/30/2010 AND <= 7/13/2010
-
The only exception would be if a field has accidentally been defined (in the copy library) as a plain character or numeric field (rather than a true date field). In that case, you do need to compare it with a character or numeric literal of the same format. In that case, you may also want to change the field's definition (in the copy library). Just locate the correct
FIELD
statement and add a
TYPE
parm that specifies one of the dozens of Date Data Types listed in Appendix A of the Reference Manual. Then you will be able to test that field using date literals. (And the field will also be formatted correctly as a date in the report output.)
Time Literals
-
Time literals should be in 24-hour
HH:MM
or
HH:MM:SS[.DDD...]
format.
Comparing Times
-
Once again, you do not need to be concerned with exactly how a time or interval field is stored in the SMF record. As long as the field is defined as a true time field, Spectrum SMF Writer automatically handles all required conversions for you. So, whether a field is stored in the record as packed seconds since midnight, character
HHMM
, an 8-byte
STCK
time, or binary microseconds since midnight (to name a few examples), you always write your comparison times in
HH:MM[:SS]
format.
-
For example, even though the
SMF14TME
field is stored in the SMF record as hundredths of a second since midnight, you will test it like this:
INCLUDEIF: SMF14RTY= 14 AND SMF14DTE = 9/1/2010 AND SMF14TME >= 13:00 AND < 14:00
-
Again, if a time field has accidentally been defined as a regular character or numeric fields then you will need to compare it with a character or numeric literal of the same format. Or you can locate the correct
FIELD
statement in the copy library and add a
TYPE
parm that specifies one of the dozens of Time Data Types listed in Appendix A of the Reference Manual. You may also need to add a
DEC(n)
parm to the
FIELD
statement, if the time field contains decimal parts of a second.
Comparing a List of Values
-
If you want to compare a field to a list of values, you can use this shorthand format:
INCLUDEIF: SMF14JBN = 'ACCT1000' OR 'ACCT1100' OR 'ACCT1200'
-
Or to exclude a list of values, use this format:
INCLUDEIF: SMF14JBN <> 'ACCT1000' AND 'ACCT1100' AND 'ACCT1200'
Syntax for Continuation Lines
-
Often the
INCLUDEIF
statement will be too long to fit on one control statement. (Spectrum SMF Writer uses columns 1 through 72 of each statement. Anything in columns 73-80 is ignored.) You may continue your
INCLUDEIF
statement onto as many lines as needed. Just be sure to begin each continuation line with a blank in column 1.
-
If you need to break a literal onto multiple lines, continue up to column 72 in one line and resume it in column 2 of the next line.
Summary
-
Here is a summary of what we learned in this lesson:
-
an
INCLUDEIF
statement is used to tell Spectrum SMF Writer which records from the input file to include in the report
-
an
INCLUDEIF statement consists of a conditional expression
-
you can compare any (true) date field in an SMF record with a
MM/DD/YY
or
MM/DD/YYYY
literal
-
you can compare any (true) time field in an SMF record with a
HH:MM
or
HH:MM:SS
literal
-
The next lesson will teach you how to turn an SMF report into an export file for PC programs.
To Learn More
-
You can also learn:
-
how to specify conditions based on bit fields
-
how to use the
STOPWHEN
parm on the
INPUT
statement to limit the records read from the SMF file
-
the complete syntax for the
INCLUDEIF
statement, in
NEXT LESSON: How to Export SMF Data to PC Programs
|